var r = require("../../@babel/runtime/helpers/typeof"), e = "function" == typeof Symbol && "symbol" == r(Symbol.iterator) ? function(e) {
    return r(e);
} : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : r(e);
};

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var t = "function" == typeof Symbol && "symbol" === e(Symbol.iterator) ? function(r) {
    return void 0 === r ? "undefined" : e(r);
} : function(r) {
    return r && "function" == typeof Symbol && r.constructor === Symbol && r !== Symbol.prototype ? "symbol" : void 0 === r ? "undefined" : e(r);
};

function o(r, e, i) {
    function s(r, e, n) {
        var i, s = this, a = [];
        for (i in o.isArray(r) && (0 === r.length && s.track(r), s.mock(r)), r && "object" === (void 0 === r ? "undefined" : t(r)) && 0 === Object.keys(r).length && s.track(r), 
        r) r.hasOwnProperty(i) && (!n || o.isArray(e) && o.isInArray(e, i) || o.isString(e) && i == e) && (a.push(i), 
        s.watch(r, i));
        s.target = r, s.propertyChangedHandler || (s.propertyChangedHandler = []);
        var p = n || e;
        s.propertyChangedHandler.push({
            all: !n,
            propChanged: p,
            eventPropArr: a
        });
    }
    return s.prototype = {
        onPropertyChanged: function(r, e, i, s, a) {
            if (e !== i && (!n(e) || !n(i)) && this.propertyChangedHandler) for (var p = o._getRootName(r, a), c = 0, u = this.propertyChangedHandler.length; c < u; c++) {
                var h = this.propertyChangedHandler[c];
                (h.all || o.isInArray(h.eventPropArr, p) || 0 === p.indexOf("Array-")) && h.propChanged.call(this.target, r, e, i, a);
            }
            0 !== r.indexOf("Array-") && "object" === (void 0 === e ? "undefined" : t(e)) && this.watch(s, r, s.$observeProps.$observerPath);
        },
        mock: function(r) {
            var e = this;
            o.methods.forEach(function(t) {
                r[t] = function() {
                    var r = Array.prototype.slice.call(this, 0), n = Array.prototype[t].apply(this, Array.prototype.slice.call(arguments));
                    if (new RegExp("\\b" + t + "\\b").test(o.triggerStr)) {
                        for (var i in this) this.hasOwnProperty(i) && !o.isFunction(this[i]) && e.watch(this, i, this.$observeProps.$observerPath);
                        e.onPropertyChanged("Array-" + t, this, r, this, this.$observeProps.$observerPath);
                    }
                    return n;
                }, r["pure" + t.substring(0, 1).toUpperCase() + t.substring(1)] = function() {
                    return Array.prototype[t].apply(this, Array.prototype.slice.call(arguments));
                };
            });
        },
        watch: function(r, e, n) {
            if ("$observeProps" !== e && "$observer" !== e && !o.isFunction(r[e])) {
                r.$observeProps || Object.defineProperty(r, "$observeProps", {
                    configurable: !0,
                    enumerable: !1,
                    writable: !0,
                    value: {}
                }), r.$observeProps.$observerPath = void 0 !== n ? n : "#";
                var i = this, s = r.$observeProps[e] = r[e];
                if (Object.defineProperty(r, e, {
                    configurable: !0,
                    get: function() {
                        return this.$observeProps[e];
                    },
                    set: function(t) {
                        var o = this.$observeProps[e];
                        this.$observeProps[e] = t, i.onPropertyChanged(e, t, o, this, r.$observeProps.$observerPath);
                    }
                }), "object" == (void 0 === s ? "undefined" : t(s))) for (var a in o.isArray(s) && (this.mock(s), 
                0 === s.length && this.track(s, e, n)), s && 0 === Object.keys(s).length && this.track(s, e, n), 
                s) s.hasOwnProperty(a) && this.watch(s, a, r.$observeProps.$observerPath + "-" + e);
            }
        },
        track: function(r, e, t) {
            r.$observeProps || (Object.defineProperty(r, "$observeProps", {
                configurable: !0,
                enumerable: !1,
                writable: !0,
                value: {}
            }), r.$observeProps.$observerPath = null != t ? t + "-" + e : null != e ? "#-" + e : "#");
        }
    }, new s(r, e, i);
}

function n(r) {
    return "number" == typeof r && isNaN(r);
}

(exports.default = o).methods = [ "concat", "copyWithin", "entries", "every", "fill", "filter", "find", "findIndex", "forEach", "includes", "indexOf", "join", "keys", "lastIndexOf", "map", "pop", "push", "reduce", "reduceRight", "reverse", "shift", "slice", "some", "sort", "splice", "toLocaleString", "toString", "unshift", "values", "size" ], 
o.triggerStr = [ "concat", "copyWithin", "fill", "pop", "push", "reverse", "shift", "sort", "splice", "unshift", "size" ].join(","), 
o.isArray = function(r) {
    return "[object Array]" === Object.prototype.toString.call(r);
}, o.isString = function(r) {
    return "string" == typeof r;
}, o.isInArray = function(r, e) {
    for (var t = r.length; -1 < --t; ) if (e === r[t]) return !0;
    return !1;
}, o.isFunction = function(r) {
    return "[object Function]" == Object.prototype.toString.call(r);
}, o._getRootName = function(r, e) {
    return "#" === e ? r : e.split("-")[1];
}, o.add = function(r, e) {
    r.$observer.watch(r, e);
}, o.set = function(r, e, t, o) {
    void 0 === r[e] && (r.$observer || o).watch(r, e, r.$observeProps.$observerPath), 
    r[e] = t;
}, Array.prototype.size = function(r) {
    this.length = r;
};